package com.school.service.impl;

import com.school.mapper.StuInfoMapper;
import com.school.model.OutPutScore;
import com.school.model.StuGradeDTO;
import com.school.model.StuScoreDTO;
import com.school.service.StuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @date 2021-04-20 20:19
 */
@Service
public class StuInfoServiceImpl implements StuInfoService {
    @Autowired
    private StuInfoMapper  stuInfoMapper;
    @Override
    public void save(StuGradeDTO stuGradeDTO) {
        stuInfoMapper.addStuInfo(stuGradeDTO.getStuNo(),stuGradeDTO.getStuName());
        List<StuScoreDTO> list = stuGradeDTO.getList();
        list.stream().forEach(e ->{
            stuInfoMapper.addStuScore(e.getStuNo(),e.getStuScore(),e.getScoreType());
        });



    }

    @Override
    public List<OutPutScore> getFinalExam() {
        return stuInfoMapper.getFinalExam();
    }

    @Override
    public List<OutPutScore> getPerformance() {
        return stuInfoMapper.getPerformance();
    }

    @Override
    public List<OutPutScore> getHomeWork() {
        return stuInfoMapper.getHomeWork();
    }

    @Override
    public List<OutPutScore> getTest() {
        return stuInfoMapper.getTest();
    }

    @Override
    public void deleteTable() {
        stuInfoMapper.truncateScoreInfo();
        stuInfoMapper.truncateStuInfo();
    }
}
